<template>
	<view>
		<head-navbar :back="true">
			<view>
				<text>参与拼团</text>
			</view>
		</head-navbar>
		<view class="content">
			<view class="box2">
				<view class="title">钻石余额</view>
				<view class="num">{{diamond}}</view>
			</view>
			<view class="box">
				<view class="select" @click="toPage(0,'/pages/group/select')">
					<view class="tip">选择账号</view>
					<view class="se">{{accountNos.length == 0?'请选择子账号':'已选择'+accountNos.length+'个账号'}}</view>
					<image class="right" src="../../static/img/right.png"></image>
				</view>
				<view class="message">
					<view class="right">总价：{{price*accountNos.length}}</view>
					<!-- <view class="left">单笔手续费：1.000000 WDT</view> -->
				</view>
			</view>
			<button class="btn"@click="join">确认</button>
		</view>
		
	</view>
</template>

<script>
	import * as api from '../../api/group/index.js'
	import * as money from '../../api/user/money.js'
	export default{
		data() {
			return {
				diamond:0,
				price:0,
				childUserIds:[],
				accountNos:[],
				groupBookLogId:'',
				show: false,
			}
		},
		onLoad(option) {
			this.getUserWalletInfo()
			this.groupBookLogId = option.groupBookLogId
			this.price = option.price
		},
		methods:{
			join(){
				if(this.accountNos.length == 0){
					uni.showToast({
						title:'请选择子账号',
						icon:'none',
					})
					return
				}
				api.join({request:{groupBookLogId:this.groupBookLogId,childUserIds:this.childUserIds,accountNos:this.accountNos}}).then(res=>{
					uni.showToast({
						title:'参团成功',
						icon:'none',
					})
					setTimeout(function(){
					   uni.navigateBack({
					   	delta: 1
					   })
					},1000)
				}).catch(err=>{
					
				})
			},
			getUserWalletInfo(){
				money.getUserWalletInfo().then(res=>{
					this.diamond = res.data.dataBody.diamond
				}).catch(err=>{
					
				})
			},
			// confirm(e) {
			// 	this.account = e[0].label;
			// },
		}
	}
</script>

<style lang="scss" scoped>
	.box2{
		padding: 30rpx;
		text-align: center;
		background: #FFFFFF;
		padding: 30rpx;
		margin-bottom: 30rpx;
		 border-radius: 20rpx;
		 box-shadow: 0rpx 0rpx 20rpx rgba(255,107,27,0.2);
		.title{
			font-size: 40rpx;
		}
		.num{
			font-weight: 600;
			margin-top: 20rpx;
			color: #FF5B02;
			font-size: 40rpx;
			font-weight: 400;
		}
	}
  .content{
	  padding: 30rpx;
	  .box{
		  background: #FFFFFF;
		  border-radius: 20rpx;
		  padding: 30rpx;
		  .select{
		  	display: flex;
		  	align-items: center;
			padding-bottom: 20rpx;
			border-bottom: 1rpx solid #f4f4f4;
		  	.tip{
		  		font-size: 32rpx;
		  		color: #000000;
				flex: auto;
		  	}
		  	.se{
		  		font-size: 24rpx;
		  		color: #949494;
				margin-right: 20rpx;
		  	}
		  	image{
		  		width: 30rpx;
		  		height: 30rpx;
		  	}
		  }
		  .message{
			  margin-top: 20rpx;
			  font-size: 24rpx;
			  display: flex;
			  align-items: center;
			  justify-content: space-between;
			  color: #949494;
		  }
	  }
	  .btn{
		  background: #FF5C02;
		  border-radius: 100rpx;
		  color: #FFFFFF;
		  margin-top: 50rpx;
	  }
  }
</style>
